﻿Public Class RPRICEPACK
    Dim connect As CONDB = CONDB.NewConnection()
    Dim PROVIDER_Check As New PROVIDERSCLASS


    Private Sub RIGHTPRICEPACKAGE_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        '-----จับคู่สิทธิ์กับผลิตภัณฑ์

        '------------หนูน้อยอะไรหว่า
        Dim s As FILTERCLASS
        Dim sql As String = "SELECT CAST(mtrgtid AS CHAR(4)) AS MTRGTID, mtrgtname, sdet FROM masmtypergt WHERE status = '1'"
        s = New FILTERCLASS(MTRGTInPrdpriceTxt, sql, "รหัสหมวดคู่สัญญา,ชื่อหมวดคู่สัญญา,มีกลุ่มย่อย", "50,160,50", "1,1,1", "1,1,0")
        's.SetShowInDown = False
        s.SetShowBorder = True

        Dim s4 As FILTERCLASS
        Dim sql4 As String = "SELECT CAST(pckpid AS CHAR(4)) AS PCKPID, pckname, remark FROM pckproduct"
        s4 = New FILTERCLASS(pckpInProductipriceTxt, sql4, "รหัสกลุ่มผลิตภัณฑ์,ชื่อกลุ่มผลิตภัณฑ์", "40,150,150", "1,1", "1,1")
        's.SetShowInDown = False
        s4.SetShowBorder = True
        '------------end of หนูน้อยอะไรหว่า
        STRGTInPrdpriceTxt.Enabled = False
        SBRGTInPrdpriceTxt.Enabled = False

        '-----end of จับคู่สิทธิ์กับผลิตภัณฑ์

        DesignForm(Me)
        DesignGrid(prdpriceGrid3)
        DesignGrid(prdpriceHistoryGrid)

        PROVIDER_Check.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub MTRGTInPrdpriceTxt_Click(sender As Object, e As EventArgs) Handles MTRGTInPrdpriceTxt.Click
        MTRGTInPrdpriceTxt.Text = ""
    End Sub

    Private Sub STRGTInPrdpriceTxt_Click(sender As Object, e As EventArgs) Handles STRGTInPrdpriceTxt.Click
        STRGTInPrdpriceTxt.Text = ""
    End Sub

    Private Sub SBRGTInPrdpriceTxt_Click(sender As Object, e As EventArgs) Handles SBRGTInPrdpriceTxt.Click
        SBRGTInPrdpriceTxt.Text = ""
    End Sub

    Private Sub pckpInProductipriceTxt_Click(sender As Object, e As EventArgs) Handles pckpInProductipriceTxt.Click
        pckpInProductipriceTxt.Text = ""
    End Sub

    Private Sub MTRGTInPrdpriceTxt_TextChanged(sender As Object, e As EventArgs) Handles MTRGTInPrdpriceTxt.TextChanged
        queryByMT()
    End Sub

    Private Sub STRGTInPrdpriceTxt_TextChanged(sender As Object, e As EventArgs) Handles STRGTInPrdpriceTxt.TextChanged
        queryByMTST()
    End Sub

    Private Sub SBRGTInPrdpriceTxt_TextChanged(sender As Object, e As EventArgs) Handles SBRGTInPrdpriceTxt.TextChanged
        queryByMTSTSB()
    End Sub

    Public Sub queryByMT()
        Dim sdetMTRGT As Boolean
        Dim sdetTable As DataTable = connect.GetTable("SELECT sdet FROM masmtypergt WHERE mtrgtid = '" & MTRGTInPrdpriceTxt.Tag & "'")
        If sdetTable.Rows.Count > 0 Then
            sdetMTRGT = sdetTable.Rows(0)(0).ToString
        End If

        If sdetMTRGT = True Then
            STRGTInPrdpriceTxt.Enabled = True

            Dim s2 As FILTERCLASS
            Dim sql2 As String = "SELECT CAST(strgtid AS CHAR(4)) AS STRGTID, strgtname, sdet FROM masstypergt WHERE status = '1' AND mtrgtid = '" & MTRGTInPrdpriceTxt.Tag & "'"
            s2 = New FILTERCLASS(STRGTInPrdpriceTxt, sql2, "รหัสกลุ่มคู่สัญญา,ชื่อกลุ่มคู่สัญญา,มีกลุ่มย่อย", "50,160,50", "1,1,1", "1,1,0")
            's.SetShowInDown = False
            s2.SetShowBorder = True
        Else
            STRGTInPrdpriceTxt.Text = ""
            SBRGTInPrdpriceTxt.Text = ""
            STRGTInPrdpriceTxt.Enabled = False
            SBRGTInPrdpriceTxt.Enabled = False
        End If

        Dim rightFilterByMTRGT As DataTable
        Dim queryString As String

        queryString = "SELECT a.`prcid` AS 'รหัสราคาสิทธิ์', a.`prdcode` AS 'รหัสผลิตภัณฑ์', b.`prdname` AS 'ชื่อผลิตภัณฑ์', a.`mtrgtid` AS 'รหัสหมวดคู่สัญญา', e.`mtrgtname` AS 'หมวดคู่สัญญา', "

        If STRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "a.`strgtid` AS 'รหัสกลุ่มคู่สัญญา', f.`strgtname` AS 'กลุ่มคู่สัญญา', "
        End If

        If SBRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "a.`sbrgtid` AS 'รหัสสิทธิ์', g.`subrgtname` AS 'สิทธิ์', "
        End If

        queryString += "a.`opdprc` AS 'OPD', a.`ipdprc` AS 'IPD', a.`stdate` AS 'เริ่มต้น', a.`endate` AS 'สิ้นสุด', a.`status` AS 'สถานะการเปิดใช้งาน' FROM prdprice a JOIN masproduct b ON a.`prdcode` = b.`prdcode` JOIN masmtypergt e ON a.`mtrgtid` = e.`mtrgtid` "

        If STRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "JOIN masstypergt f ON a.`strgtid` = f.`strgtid` "
        End If

        If SBRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "JOIN massubrgt g ON a.`sbrgtid` = g.`sbrgtid` "
        End If

        queryString += "WHERE a.`mtrgtid` = '" & MTRGTInPrdpriceTxt.Tag & "' "

        If STRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "AND a.`strgtid` = '" & STRGTInPrdpriceTxt.Tag & "' "
        ElseIf STRGTInPrdpriceTxt.Tag = 0 Then
            queryString += "AND a.`strgtid` IS NULL "
        End If

        If SBRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "AND a.`sbrgtid` = '" & SBRGTInPrdpriceTxt.Tag & "' "
        ElseIf SBRGTInPrdpriceTxt.Tag = 0 Then
            queryString += "AND a.`sbrgtid` IS NULL "
        End If

        'queryString += "AND a.`F_PRO` = '0' AND NOW() BETWEEN a.`STDATE` AND a.`ENDATE`"
        queryString += "AND a.`f_pro` = '0' AND (NOW() BETWEEN a.`stdate` AND a.`endate` OR a.stdate > NOW()) GROUP BY a.prdcode"

        rightFilterByMTRGT = connect.GetTable(queryString)
        prdpriceGrid1.PrimaryGrid.DataSource = rightFilterByMTRGT

        prdpriceGrid1.Visible = True
        prdpriceGrid2.Visible = False
        prdpriceGrid3.Visible = False
    End Sub

    Public Sub queryByMTST()
        Dim sdetSTRGT As Boolean
        Dim sdetTable As DataTable = connect.GetTable("SELECT sdet FROM masstypergt WHERE strgtid = '" & STRGTInPrdpriceTxt.Tag & "'")
        If sdetTable.Rows.Count > 0 Then
            sdetSTRGT = sdetTable.Rows(0)(0).ToString
        End If

        If sdetSTRGT = True Then
            SBRGTInPrdpriceTxt.Enabled = True

            Dim s3 As FILTERCLASS
            Dim sql3 As String = "SELECT CAST(sbrgtid AS CHAR(4)) AS SBRGTID, subrgtname FROM massubrgt WHERE status = '1' AND strgtid = '" & STRGTInPrdpriceTxt.Tag & "'"
            s3 = New FILTERCLASS(SBRGTInPrdpriceTxt, sql3, "รหัสผลิตภัณฑ์,ชื่อผลิตภัณฑ์", "50,160", "1,1", "1,1")
            's.SetShowInDown = False
            s3.SetShowBorder = True
        Else
            SBRGTInPrdpriceTxt.Enabled = False
            SBRGTInPrdpriceTxt.Text = ""
        End If

        Dim rightFilterBySTRGT As DataTable
        Dim queryString As String

        queryString = "SELECT a.`prcid` AS 'รหัสราคาสิทธิ์', a.`prdcode` AS 'รหัสผลิตภัณฑ์', b.`prdname` AS 'ชื่อผลิตภัณฑ์', a.`mtrgtid` AS 'รหัสหมวดคู่สัญญา', e.`mtrgtname` AS 'หมวดคู่สัญญา', a.`strgtid` AS 'รหัสกลุ่มคู่สัญญา', f.`strgtname` AS 'กลุ่มคู่สัญญา', "

        If SBRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "a.`sbrgtid` AS 'รหัสสิทธิ์', g.`subrgtname` AS 'สิทธิ์', "
        End If

        queryString += "a.`opdprc` AS 'OPD', a.`ipdprc` AS 'IPD', a.`stdate` AS 'เริ่มต้น', a.`endate` AS 'สิ้นสุด', a.`status` AS 'สถานะการเปิดใช้งาน' FROM prdprice a JOIN masproduct b ON a.`prdcode` = b.`prdcode` JOIN masmtypergt e ON a.`mtrgtid` = e.`mtrgtid` JOIN masstypergt f ON a.`strgtid` = f.`strgtid` "

        If SBRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "JOIN massubrgt g ON a.`sbrgtid` = g.`sbrgtid` "
        End If

        queryString += "WHERE a.`mtrgtid` = '" & MTRGTInPrdpriceTxt.Tag & "' AND a.`strgtid` = '" & STRGTInPrdpriceTxt.Tag & "' "

        If SBRGTInPrdpriceTxt.Tag <> 0 Then
            queryString += "AND a.`sbrgtid` = '" & SBRGTInPrdpriceTxt.Tag & "' "
        ElseIf SBRGTInPrdpriceTxt.Tag = 0 Then
            queryString += "AND a.`sbrgtid` IS NULL "
        End If

        'queryString += "AND a.`F_PRO` = '0' AND NOW() BETWEEN a.`STDATE` AND a.`ENDATE`"
        queryString += "AND a.`f_pro` = '0' AND (NOW() BETWEEN a.`stdate` AND a.`endate` OR a.stdate > NOW()) GROUP BY a.prdcode"

        rightFilterBySTRGT = connect.GetTable(queryString)
        'prdpriceGrid2.PrimaryGrid.Columns.Clear()
        prdpriceGrid2.PrimaryGrid.DataSource = rightFilterBySTRGT

        prdpriceGrid1.Visible = False
        prdpriceGrid2.Visible = True
        prdpriceGrid3.Visible = False
    End Sub

    Public Sub queryByMTSTSB()
        Dim rightFilterBySBRGT As DataTable
        Dim queryString As String

        'queryString = "SELECT a.`PRCID` AS 'รหัสราคาสิทธิ์', a.`PRDCODE` AS 'รหัสผลิตภัณฑ์', b.`PRDNAME` AS 'ชื่อผลิตภัณฑ์', a.`MTRGTID` AS 'รหัสหมวดคู่สัญญา', e.`MTRGTNAME` AS 'หมวดคู่สัญญา', a.`STRGTID` AS 'รหัสกลุ่มคู่สัญญา', f.`STRGTNAME` AS 'กลุ่มคู่สัญญา', a.`SBRGTID` AS 'รหัสสิทธิ์', g.`SUBRGTNAME` AS 'สิทธิ์', a.`OPDPRC` AS 'OPD', a.`IPDPRC` AS 'IPD', a.`STDATE` AS 'เริ่มต้น', a.`ENDATE` AS 'สิ้นสุด', a.`STATUS` AS 'สถานะการเปิดใช้งาน' FROM prdprice a JOIN masproduct b ON a.`PRDCODE` = b.`PRDCODE` JOIN masmtypergt e ON a.`MTRGTID` = e.`MTRGTID` JOIN masstypergt f ON a.`STRGTID` = f.`STRGTID` JOIN massubrgt g ON a.`SBRGTID` = g.`SBRGTID` WHERE a.`MTRGTID` = '" & MTRGTInPrdpriceTxt.Tag & "' AND a.`STRGTID` = '" & STRGTInPrdpriceTxt.Tag & "' AND a.`SBRGTID` = '" & SBRGTInPrdpriceTxt.Tag & "' AND a.`F_PRO` = '0' AND NOW() BETWEEN a.`STDATE` AND a.`ENDATE`"
        queryString = "SELECT a.`prcid` AS 'รหัสราคาสิทธิ์', a.`prdcode` AS 'รหัสผลิตภัณฑ์', b.`prdname` AS 'ชื่อผลิตภัณฑ์', a.`mtrgtid` AS 'รหัสหมวดคู่สัญญา', e.`mtrgtname` AS 'หมวดคู่สัญญา', a.`strgtid` AS 'รหัสกลุ่มคู่สัญญา', f.`strgtname` AS 'กลุ่มคู่สัญญา', a.`sbrgtid` AS 'รหัสสิทธิ์', g.`subrgtname` AS 'สิทธิ์', a.`opdprc` AS 'OPD', a.`ipdprc` AS 'IPD', a.`stdate` AS 'เริ่มต้น', a.`endate` AS 'สิ้นสุด', a.`status` AS 'สถานะการเปิดใช้งาน' FROM prdprice a JOIN masproduct b ON a.`prdcode` = b.`prdcode` JOIN masmtypergt e ON a.`mtrgtid` = e.`mtrgtid` JOIN masstypergt f ON a.`strgtid` = f.`strgtid` JOIN massubrgt g ON a.`sbrgtid` = g.`sbrgtid` WHERE a.`mtrgtid` = '" & MTRGTInPrdpriceTxt.Tag & "' AND a.`strgtid` = '" & STRGTInPrdpriceTxt.Tag & "' AND a.`sbrgtid` = '" & SBRGTInPrdpriceTxt.Tag & "' AND a.`f_pro` = '0' AND (NOW() BETWEEN a.`stdate` AND a.`endate` OR a.stdate > NOW()) GROUP BY a.prdcode"
        rightFilterBySBRGT = connect.GetTable(queryString)
        'prdpriceGrid3.PrimaryGrid.Columns.Clear()
        prdpriceGrid3.PrimaryGrid.DataSource = rightFilterBySBRGT

        prdpriceGrid1.Visible = False
        prdpriceGrid2.Visible = False
        prdpriceGrid3.Visible = True
    End Sub


    Private Sub prdpriceGrid1_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles prdpriceGrid1.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        'f.TXT_CID.Text = grid.Cells.Item(2).Value
        MTRGTInPrdpriceTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("หมวดคู่สัญญา").Value()

        Try
            STRGTInPrdpriceTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("กลุ่มคู่สัญญา").Value()
        Catch ex As NullReferenceException
            STRGTInPrdpriceTxt.Text = ""
        End Try

        Try
            SBRGTInPrdpriceTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สิทธิ์").Value()
        Catch ex As NullReferenceException
            SBRGTInPrdpriceTxt.Text = ""
        End Try

        STDATEDate.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("เริ่มต้น").Value()
        ENDATEDate.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สิ้นสุด").Value()
        opdPrice.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("OPD").Value()
        ipdPrice.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("IPD").Value()

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            prdpriceStatusChk.Checked = True
        Else
            prdpriceStatusChk.Checked = False
        End If

        queryPrdpriceHistory(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหมวดคู่สัญญา").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสกลุ่มคู่สัญญา").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสสิทธิ์").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสผลิตภัณฑ์").Value())
    End Sub

    Private Sub prdpriceGrid2_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles prdpriceGrid2.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow

        queryPrdpriceHistory(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหมวดคู่สัญญา").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสกลุ่มคู่สัญญา").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสสิทธิ์").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสผลิตภัณฑ์").Value())
    End Sub

    Private Sub prdpriceGrid3_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles prdpriceGrid3.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow

        queryPrdpriceHistory(CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสหมวดคู่สัญญา").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสกลุ่มคู่สัญญา").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสสิทธิ์").Value(), CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสผลิตภัณฑ์").Value())
    End Sub

    Public Sub queryPrdpriceHistory(ByVal MTRGTID As Integer, ByVal STRGTID As Integer, ByVal SBRGTID As Integer, ByVal PRDCODE As Integer)
        Dim queryString As String
        queryString = "SELECT opdprc AS 'OPD', ipdprc AS 'IPD',stdate AS 'วันเริ่มต้น', endate AS 'วันสิ้นสุด' FROM prdprice WHERE mtrgtid = '" & MTRGTID & "' "

        If STRGTID <> 0 Then
            queryString += "AND strgtid = '" & STRGTID & "' "
        ElseIf STRGTID = 0 Then
            queryString += "AND strgtid IS NULL "
        End If

        If SBRGTID <> 0 Then
            queryString += "AND sbrgtid = '" & SBRGTID & "' "
        ElseIf SBRGTID = 0 Then
            queryString += "AND sbrgtid IS NULL "
        End If

        queryString += "AND  prdcode = '" & PRDCODE & "' GROUP BY opdprc, ipdprc ORDER BY stdate DESC"

        Dim prdpriceHistoryData As DataTable
        prdpriceHistoryData = connect.GetTable(queryString)
        prdpriceHistoryGrid.PrimaryGrid.DataSource = prdpriceHistoryData

        Me.Refresh()

        For i As Integer = 0 To prdpriceHistoryData.Rows.Count - 1
            Dim dateStart As Date
            Dim dateEnd As Date
            dateStart = prdpriceHistoryData.Rows(i)("วันเริ่มต้น")
            dateEnd = prdpriceHistoryData.Rows(i)("วันสิ้นสุด")

            Dim result1 As Integer = DateTime.Compare(dateStart, Now)
            Dim result2 As Integer = DateTime.Compare(dateEnd, Now)

            'Dim result1 As Integer = DateDiff(DateInterval.Day, dateStart, Date.Now)
            'Dim result2 As Integer = DateDiff(DateInterval.Day, dateEnd, Date.Now)

            'MsgBox(result1 & "/" & result2)

            If result1 < 0 And result2 < 0 Then
                'MsgBox("past")
                CType(prdpriceHistoryGrid.PrimaryGrid.Rows(i), DevComponents.DotNetBar.SuperGrid.GridRow).CellStyles.Default.Background.Color1 = Color.FromArgb(179, 179, 179)
            ElseIf result1 <= 0 And result2 >= 0 Then
                'MsgBox("present")
                CType(prdpriceHistoryGrid.PrimaryGrid.Rows(i), DevComponents.DotNetBar.SuperGrid.GridRow).CellStyles.Default.Background.Color1 = Color.FromArgb(171, 217, 93)
            ElseIf result1 > 0 And result2 > 0 Then
                'MsgBox("future")
                CType(prdpriceHistoryGrid.PrimaryGrid.Rows(i), DevComponents.DotNetBar.SuperGrid.GridRow).CellStyles.Default.Background.Color1 = Color.FromArgb(122, 156, 255)
            End If
        Next
    End Sub

    Private Sub submitPriceBtn_Click(sender As Object, e As EventArgs) Handles submitPriceBtn.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If MTRGTInPrdpriceTxt.Text.ToString.Length > 0 And pckpInProductipriceTxt.Text.ToString.Length > 0 And opdPrice.Text.ToString.Length > 0 And ipdPrice.Text.ToString.Length > 0 Then
                    Dim result As Integer = DateTime.Compare(STDATEDate.Value.Date, DateTime.Now.Date)
                    If result > 0 Then
                        Dim objInsertData As New RIGHTPRDPRICE
                        objInsertData.MTRGTID_ = MTRGTInPrdpriceTxt.Tag
                        objInsertData.STRGTID_ = STRGTInPrdpriceTxt.Tag
                        objInsertData.SBRGTID_ = SBRGTInPrdpriceTxt.Tag
                        objInsertData.PCKPID_ = pckpInProductipriceTxt.Tag
                        objInsertData.OPDPRC_ = opdPrice.Text
                        objInsertData.IPDPRC_ = ipdPrice.Text
                        objInsertData.STDATE_ = STDATEDate.Value.Date
                        objInsertData.ENDATE_ = "9456-09-09"
                        objInsertData.STATUS_ = prdpriceStatusChk.Checked
                        objInsertData.addPrdpricePackage()

                        If MTRGTInPrdpriceTxt.Tag <> 0 And STRGTInPrdpriceTxt.Tag <> 0 And SBRGTInPrdpriceTxt.Tag <> 0 Then
                            queryByMTSTSB()
                        ElseIf MTRGTInPrdpriceTxt.Tag <> 0 And STRGTInPrdpriceTxt.Tag <> 0 Then
                            queryByMTST()
                        ElseIf MTRGTInPrdpriceTxt.Tag <> 0 Then
                            queryByMT()
                        End If
                        'queryPrdpriceHistory(MTRGTInPrdpriceTxt.Tag, STRGTInPrdpriceTxt.Tag, SBRGTInPrdpriceTxt.Tag, )
                    Else
                        MsgBox("ต้องระบุวันที่ในอนาคตเท่านั้น")
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub
End Class